﻿ 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 
<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="../../css/style.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="../../css/menu.css">

	<script src="../../script/jquery-3.3.1.min.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../../js/bootstrap.min.js"></script>
	<script src="../../../js/vue.js"></script>
</head>
  <body>
  <div id="add">
   	<div class="page_title">权限管理 > 用户管理 > 添加系统用户</div>
   		<input type="hidden" name="method" value="addSysUser">
	   	<div class="button_bar">
	   		<button class="common_button" onclick="help('');">帮助</button>
	   		<button class="common_button" onclick="back();">返回</button>
			<button class="common_button" @click="myAdd();">保存</button>
	   	</div>
	   	<table class="query_form_table">
	   		<tr>
	   			<th>编号</th>
	   			<td>
	   				<input type="text" disabled="disabled"/>
	   			</td>
	   			<th>用户名</th>
	   			<td>
	   				<input type="text"  size="20" v-model="usr.usr_name" @input="bbb()">
					<span class="red_star" id="name">*</span>
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>密码</th>
	   			<td>
	   				<input type="password" v-model="usr.usr_password" size="20">
					<span class="red_star" >*</span>
	   			</td>
	   			<th>
	   				状态
	   			</th>
	   			<td>
	   				正常
	   				<input type="hidden" v-model="usr.usr_flag">
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>角色</th>
	   			<td>
	   				未指派
	   			</td>
	   		</tr>
	   	</table>
  </div>
  </body>
<script>
	var app = new Vue({
		el:'#add',
		data:{
			usr:{
                usr_name:'',
                usr_password:'',
                usr_flag:1,
			}
		},
		methods:{
            myAdd(){
                if(this.usr.usr_name==''||null){
					alert("必填项存在空值")
					return
				}
                if(this.usr.usr_password==''||null){
                    alert("必填项存在空值")
                    return
                }
				$.getJSON("/savesysuser",this.usr,function (json) {
					if(json.code==200){
						alert("新建用户成功！！！");
						location="list.html";
					}else{
					    alert("服务器异常！")
					}
                });
			},
			bbb(){
                $.getJSON("/selectusrname",{"value":this.usr.usr_name},function (json) {
					document.getElementById("name").innerHTML=json.data.tishi;
					if(app.usr.usr_name==''){
                        document.getElementById("name").innerHTML="用户名不能为空";
					}
                });
			}
		}
	});
</script>
</html>
